package com.codding.springboot_mybatisdemo.mapper;

import com.codding.springboot_mybatisdemo.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AdminMapper {

    @Select("SELECT admin_id, admin_name AS adminName, admin_password AS adminPassword " +
            "FROM admin " +
            "WHERE admin_name = #{adminName} AND admin_password = #{adminPassword}")
    Admin login(Admin admin);

    @Select("select admin.admin_id,admin.admin_name as adminName,admin.admin_password as adminPassword from admin\n" +
            "where admin_name='#{name}' and admin_password='#{pwd}';")
    Admin login1(
            @Param("name") String adminName,
            @Param("pwd") String adminPassword
    );

    @Select("select admin_id, admin_name as adminName, admin_password as adminPassword from admin \n" +
            "where admin_name = #{value};")
    Admin selectByName(String name);

    @Insert("insert into admin values(default,#{adminName}, #{adminPassword});")
    Integer register(Admin admin);
}
